//
//  ST_EditMyInfoHeaderView.swift
//  btvideo
//
//  Created by mac on 2020/1/8.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SnapKit

class ST_EditMyInfoHeaderView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(pairsHeader)
        
        self.addSubview(video_progress_view)
        video_progress_view.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-6)
            make.height.equalTo(ST_PlayVideoProgressView.height)
        }
        
        pairsHeader.progress_closure = { progress,idx in
            self.video_progress_view.setProgress(percentValue: progress, currentIdx: idx)
        }
        
        self.addSubview(click_btn)
        click_btn.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-32)
            make.width.equalTo(162)
            make.height.equalTo(35)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

//    MARK: - 进度条
    fileprivate lazy var video_progress_view:ST_PlayVideoProgressView = {
        let control = ST_PlayVideoProgressView()
        return control
    }()
//    MARK: - Properties
    
    var phDelegate:ST_PairsShareParticularViewDelegate?{
        didSet{
            pairsHeader.phDelegate = self.phDelegate
        }
    }
    
    lazy var pairsHeader:ST_PairsShareParticularView = {
        let control = ST_PairsShareParticularView()
        control.frame = CGRect.init(x: 0, y: 0, width: ScreenWidth, height: 100)
        return control
    }()
    
    lazy var click_btn:UIButton = {
                
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.backgroundColor = UIColor.init(hexString: "#FEC207")
        control.cornerRadius = 35/2.0
//        control.borderColor = Color.init(white: 0, alpha: 0.1)
//        control.borderWidth = 1
        control.setTitleForAllStates("编辑个人照片")
        control.setTitleColorForAllStates(UIColor.white)
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        control.addTarget(self, action: #selector(push_edit_photos_handle), for: UIControl.Event.touchUpInside)
        control.isHidden = true
        return control
    }()
    
    fileprivate var data_array = [ST_PairsShareParticularModel]()

    var pushClosure:(()->())?
    //    MARK: - Set UP Data
    func setUp(data_array:[ST_PairsShareParticularModel]){
        
        pairsHeader.setUp(data_array: data_array)
        
        self.data_array = data_array
        
        video_progress_view.create_items(count: data_array.count)
        
        video_progress_view.isHidden = data_array.count < 2
    }
}

extension ST_EditMyInfoHeaderView{
    
    @objc func push_edit_photos_handle(){
        pushClosure?()
    }
    
}
